package com.server.dao;

import com.server.pojo.MobileApp;
import com.server.pojo.MobileAppNotice;
import com.server.pojo.Notice;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface MobileAppNoticeDao extends JpaRepository<MobileAppNotice,Integer> {
    @Query("SELECT mn.notice FROM MobileAppNotice mn where mn.mobileApp = :mobileApp ORDER BY mn.notice.createdAt DESC")
    Page<Notice> getNotice(@Param("mobileApp") MobileApp mobileApp, Pageable pageable);

    @Query("SELECT mn.notice FROM MobileAppNotice mn where mn.mobileApp = :mobileApp ORDER BY mn.notice.createdAt DESC")
    List<Notice> getNotice(@Param("mobileApp") MobileApp mobileApp);

    @Query("SELECT mn.mobileApp FROM MobileAppNotice mn where mn.notice = :notice")
    List<MobileApp> getMobileApps(@Param("notice")Notice notice);

}
